rm(list = ls())


# Set Working Directory to Replication Folder
taskdir 		<- "~/Dropbox/final_hai_perlman_replication/"
surveydir 		<- paste0(projectdir, "Data/surveys/")


setwd(taskdir)
library(tidyverse)
library(lfe)
require(data.table)
library(stringi)


## load survey 1 & survey 2
survey1 <- read_csv(paste0(taskdir, 'input/survey1.csv'))
survey2 <- read_csv(paste0(taskdir, 'input/survey2.csv'))



# Define all DVs
dvs <- c('politician_understand' ,'politician_prevent' ,
		'politician_advocate' ,'politician_sympathy',
		'tax_support')

# Summary statistics in control condition
# Survey 1
survey1%>%
	filter((democrat == 1 | republican==1) & treat==0)%>%
	mutate(partylabel = ifelse(republican==0, "Democrat", "Republican"))%>%
sumtable(group = 'partylabel',
			vars = dvs,
			labels = c("has a good understanding of wildfires and their causes?",
						"will work to prevent future wildfires?",
						"will be an effective advocate for federal disaster relief?",
						"How sympathetic or unsympathetic did the politician seem towards those impacted?",
						"How likely would you be to support the new tax?"
						),
			summ = c('notNA(x)','mean(x)','sd(x)'),
			summ.names = c("N", "Mean", "SD"),
			out = 'latex',
			file = paste0(taskdir,'output/descriptive_tables/sumstats_DV_control_survey1.tex'))
# Survey 2
survey2%>%
	filter((democrat == 1 | republican==1) & treat==0)%>%
	mutate(partylabel = ifelse(republican==0, "Democrat", "Republican"))%>%
sumtable(group = 'partylabel',
			vars = dvs,
			labels = c("has a good understanding of wildfires and their causes?",
						"will work to prevent future wildfires?",
						"will be an effective advocate for federal disaster relief?",
						"How sympathetic or unsympathetic did the politician seem towards those impacted?",
						"How likely would you be to support the new tax?"
						),
			summ = c('notNA(x)','mean(x)','sd(x)'),
			summ.names = c("N", "Mean", "SD"),
			out = 'latex',
			file = paste0(taskdir,'output/descriptive_tables/sumstats_DV_control_survey2.tex'))















